package com.weipt.oper;

import javax.management.relation.RoleUnresolved;

/**
 * @program: Learning
 * @description:  利用sleep，模拟倒计时
 * @Company: 汇华(北京)信息咨询服务有限公司
 * @author: peter.wei
 * @create: 2020-07-25 10:17
 **/
public class Sleep {
    static class MyRunnable implements Runnable{
        int num = 10;
        @Override
        public void run() {
            while (true){
                if(num <= 0){
                    break;
                }
                System.out.println(Thread.currentThread().getName()+"--->倒计时："+num--);
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }
    }

    public static void main(String[] args) {
        MyRunnable myRunnable = new MyRunnable();
        Thread t = new Thread(myRunnable);
        t.start();
    }
}


